<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Report extends MY_Controller {

	public $data 	= 	array();
 	public $_template = array();
	public function __construct() {
		//parent::Controller();
		parent::__construct(); //for CI 2.x users 
		$this->load->module_model('member', 'qlsv_model', 'hocphi');
		$this->load->module_language('member', 'qlsv');
		$this->load->helper('text');
		$this->user = $this->access->get_user();
		$this->load->helper('url');
		$this->access->restrict();
	}
	
	public function index()
	{
		$data['dulieu'] = $this->hocphi->datahocphisend();
		$this->system_library->get_site_info();
		//config sendmail	
		$this->load->library('email');
		
		//use for gmail
		$config['protocol']    = 'smtp';
        $config['smtp_host']    = 'ssl://smtp.gmail.com';
        $config['smtp_port']    = '465';
        $config['smtp_timeout'] = '7';
        $config['smtp_user']    = 'ledancuoi@gmail.com'; // địa chỉ gmail
        $config['smtp_pass']    = 'qhe7211lad'; // pass gmail
        $config['charset']    = 'utf-8';
        $config['newline']    = "\r\n";
        $config['mailtype'] = 'html'; // or html
        $config['validation'] = TRUE; // bool whether to validate email or not
        $config['wordwrap'] = FALSE;      
        $this->email->initialize($config);
        
        //send mail
        $this->email->from($this->system_library->settings['admin_email'], $this->system_library->settings['site_name']);
        $this->email->to($this->system_library->settings['admin_email']);
        $this->email->subject('Danh sách thu học phí - '.'Ngày '.date('d').', tháng '.date('m').', năm '.date('Y'));
        
       
        //load view email template
        $msg = $this->load->view('sendlisthocphi', $data, true);
		$this->email->message($msg);  
        $this->email->send();
        $this->session->set_flashdata('message', 'Gửi báo cáo thành công tới Email: '.$this->system_library->settings['admin_email']);	
        redirect('member/users/', 'refresh');	
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/products.php */